package models

import "github.com/astaxie/beego/orm"

type ForumPost struct {
	Id       int    `orm:"column(pid);pk"`
	Fid      int    `json:"fid"`
	Tid      int    `json:"tid"`
	First    int    `json:"first"`
	Author   string `json:"author"`
	Authorid int    `json:"authorid"`
	Subject  string `json:"subject"`
	Dateline int64  `json:"dateline"`
	Message  string `json:"message"`
	Useip    string `json:"useip"`
	Port     int    `json:"port"`
	Usesig   int    `json:"usesig"`
	Htmlon   int    `json:"htmlon"`
}

func (m *ForumPost) TableName() string {
	return TableName("pre_forum_post")
}

func GetMaxTid() (maxTid ForumPost) {
	o := orm.NewOrm()
	qs := o.QueryTable("pre_forum_post")
	qs.OrderBy("-tid").One(&maxTid)
	return
}

func AddForumPost(m *ForumPost) (id int64, err error) {
	o := orm.NewOrm()
	id, err = o.Insert(m)
	return
}
